// 如果在一个类中涉及了动态内存的申请，那么需要重写拷贝构造函数和赋值运算符的重写
#include <string.h>
using namespace std;
class baseDMA{
private:
    char* label;
    int n;
public:
    baseDMA(const char* l = "null",int n = 0){
        label = new char[n];
        *label = *l;
    }
    baseDMA(const baseDMA& rs){
        this->label = rs.label;
        this->n = rs.n;
    }
    virtual ~baseDMA();
    baseDMA& operator=(const baseDMA& rs);
};

class hasDMA: public baseDMA{
private:
    char* style;
public:
    hasDMA(const hasDMA& hs) 
    :baseDMA(hs){
        style = new char[strlen(hs.style)+1];
        strcpy(style,hs.style);
    }
    hasDMA& operator=(const hasDMA& hs){
        if(this == &hs)return *this;
        baseDMA::operator=(hs);
        delete[] style;
        style = new char[strlen(hs.style)+1];
        strcpy(style,hs.style);
        return *this;
    }
};
